<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>注册</title>
    <link href="../css/bootstrap.min.css" rel="stylesheet">
</head>
<body>

<div class="container">

    <form class="form-horizontal" style="width: 400px; margin: 100px auto" action="">
        <div class="form-group">
            <label for="name" class="col-sm-2 control-label">账号</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="name" placeholder="账号">
            </div>
        </div>
        <div class="form-group">
            <label for="password" class="col-sm-2 control-label">密码</label>
            <div class="col-sm-10">
                <input type="password" class="form-control" id="password" placeholder="密码">
            </div>
        </div>
        <div class="form-group">
            <label for="tel" class="col-sm-2 control-label">电话</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="tel" placeholder="电话">
            </div>
        </div>
        <div class="form-group">
            <label for="address" class="col-sm-2 control-label">地址</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="address" placeholder="地址">
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="button" class="btn btn-default" id="subBtn">提交</button>
            </div>
        </div>
    </form>
</div>

<script src="../js/jquery-3.2.1.js"></script>
<script>
    $("#subBtn").click(function () {
        $.ajax({
            url: "/user/register",
            type: "post",
            data: {
                name: $("#name").val(),
                password: $("#password").val(),
                tel: $("#tel").val(),
                address: $("#address").val()
            },
            success: function (result) {
                if (result) {
                    alert("注册成功，请登录")
                } else {
                    alert("注册失败！")
                }
            }
        })
    });
</script>

</body>
</html>